package com.gonsin.gview.model.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 菜单类型
 */
public enum MenuType {

    INTERNAL(1, "内部菜单"),
    CUSTOM(2, "自定义菜单"),
    ;

    private Integer type;

    private String name;

    MenuType(Integer type, String name){
        this.type = type;
        this.name = name;
    }

    public Integer getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    /**
     * 获取列表
     *
     * @return
     */
    public static List<Map<String, Object>> list() {
        return Arrays.stream(values()).map(a -> {
            Map<String, Object> m = new HashMap<>();
            m.put("type", a.getType());
            m.put("name", a.getName());
            return m;
        }).collect(Collectors.toList());
    }



    public static MenuType get(String type){
        return Arrays.stream(MenuType.values()).filter(u -> u.getType().equals(type)).findFirst().orElse(null);
    }
}
